﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    class Food
    {
        private Point p;
        private PictureBox pb;
        private int sizeWinX;
        private int sizeWinY;

        public Food(Form1 form)
        {
            sizeWinX = form.Size.Width;
            sizeWinY = form.Size.Height;

            pb = new PictureBox();

            Random random = new Random();
            int x = random.Next(0, 30);
            int y = random.Next(0, 30);

            p.X = x * 15;
            p.Y = y * 15;

            pb.Width = 15;
            pb.Height = 15;
            pb.BackColor = Color.Red;
            pb.Location = p;
        }

        public void Generate() {
            Random random = new Random();
            p.X = random.Next(0, sizeWinX);
            p.Y = random.Next(0, sizeWinY);
            pb.Location = p;
        }

        public void Draw(Form1 form) {
            form.Controls.Add(pb);
        }
    }
}
